namespace pos.entity
{
using System;
using System.Data;
using System.Configuration;
using System.Text;
using System.Data.OleDb;
using System.Collections;
using System.Windows.Forms;
using NHibernate;
using NHibernate.Criterion;
/// <summary>
/// t_storage 的摘要说明
/// </summary>
public class t_storage:IEntityUtil
{
	//   列名称哈希表 
	private static Hashtable m_colLabels;    	 
	public static Hashtable colLabels//
	{
		get{return m_colLabels;}
	}
	//表字段名称哈希表
	private static ArrayList m_colNames;     
	public static ArrayList  colNames　
	{
		get{return m_colNames;}
	}
	private Storage __storage;
	public long seqID  
	{
		get{return __storage.seqID;}
		set{ __storage.seqID=value;}
	}
	public String commodityID  
	{
		get{return __storage.commodityID;}
		set{ __storage.commodityID=value;}
	}
	public double storagePrice  
	{
		get{return __storage.storagePrice;}
		set{ __storage.storagePrice=value;}
	}
	public double storageAmount  
	{
		get{return __storage.storageAmount;}
		set{ __storage.storageAmount=value;}
	}
	public double storageMoney  
	{
		get{return __storage.storageMoney;}
		set{ __storage.storageMoney=value;}
	}
	public double unitAmount  
	{
		get{return __storage.unitAmount;}
		set{ __storage.unitAmount=value;}
	}
	public double onSaleAmount  
	{
		get{return __storage.onSaleAmount;}
		set{ __storage.onSaleAmount=value;}
	}
	public double saleAmount  
	{
		get{return __storage.saleAmount;}
		set{ __storage.saleAmount=value;}
	}
	public double saleMoney  
	{
		get{return __storage.saleMoney;}
		set{ __storage.saleMoney=value;}
	}
	public double saleCostMoney  
	{
		get{return __storage.saleCostMoney;}
		set{ __storage.saleCostMoney=value;}
	}
	public double stockAmount  
	{
		get{return __storage.stockAmount;}
		set{ __storage.stockAmount=value;}
	}
	public double stockMoney  
	{
		get{return __storage.stockMoney;}
		set{ __storage.stockMoney=value;}
	}
	public double returnedAmount  
	{
		get{return __storage.returnedAmount;}
		set{ __storage.returnedAmount=value;}
	}
	public double returnedMoney  
	{
		get{return __storage.returnedMoney;}
		set{ __storage.returnedMoney=value;}
	}
	public double returnedCostMoney  
	{
		get{return __storage.returnedCostMoney;}
		set{ __storage.returnedCostMoney=value;}
	}
	public double lossMoney  
	{
		get{return __storage.lossMoney;}
		set{ __storage.lossMoney=value;}
	}
	private static  StorageDao dao=(StorageDao)SpringContext.Context.GetObject("StorageDao");
	public static StorageDao DAO
	{
		get{return dao;}
		
	}
	
	public t_storage()
	{
		__storage=new Storage();
	  	seqID=consts.long_min;
	  	commodityID="";
	  	storagePrice=consts.double_min;
	  	storageAmount=consts.double_min;
	  	storageMoney=consts.double_min;
	  	unitAmount=consts.double_min;
	  	onSaleAmount=consts.double_min;
	  	saleAmount=consts.double_min;
	  	saleMoney=consts.double_min;
	  	saleCostMoney=consts.double_min;
	  	stockAmount=consts.double_min;
	  	stockMoney=consts.double_min;
	  	returnedAmount=consts.double_min;
	  	returnedMoney=consts.double_min;
	  	returnedCostMoney=0;
	  	lossMoney=0;
	  // dao=(StorageDao)SpringContext.Context.GetObject("StorageDao");
	   if(m_colLabels==null)
	   {
		m_colLabels = new Hashtable();
        m_colNames= new ArrayList();
		m_colLabels.Add("seqID", @"编号");
		colNames.Add("seqID");
		m_colLabels.Add("commodityID", @"商品条码");
		colNames.Add("commodityID");
		m_colLabels.Add("storagePrice", @"库存均价");
		colNames.Add("storagePrice");
		m_colLabels.Add("storageAmount", @"库存量");
		colNames.Add("storageAmount");
		m_colLabels.Add("storageMoney", @"库存额");
		colNames.Add("storageMoney");
		m_colLabels.Add("unitAmount", @"单位");
		colNames.Add("unitAmount");
		m_colLabels.Add("onSaleAmount", @"上架数量");
		colNames.Add("onSaleAmount");
		m_colLabels.Add("saleAmount", @"销售量");
		colNames.Add("saleAmount");
		m_colLabels.Add("saleMoney", @"销售额");
		colNames.Add("saleMoney");
		m_colLabels.Add("saleCostMoney", @"销售成本");
		colNames.Add("saleCostMoney");
		m_colLabels.Add("stockAmount", @"入库数量");
		colNames.Add("stockAmount");
		m_colLabels.Add("stockMoney", @"入库金额");
		colNames.Add("stockMoney");
		m_colLabels.Add("returnedAmount", @"退货数量");
		colNames.Add("returnedAmount");
		m_colLabels.Add("returnedMoney", @"退货金额");
		colNames.Add("returnedMoney");
		m_colLabels.Add("returnedCostMoney", @"退货成本");
		colNames.Add("returnedCostMoney");
		m_colLabels.Add("lossMoney", @"损耗金额");
		colNames.Add("lossMoney");
	  }
	
	}
	public t_storage(Storage entity )
	{
		__storage=entity;
		
	  // dao=(StorageDao)SpringContext.Context.GetObject("StorageDao");
	   if(m_colLabels==null)
	   {
		m_colLabels = new Hashtable();
        m_colNames= new ArrayList();
		m_colLabels.Add("seqID", @"编号");
		colNames.Add("seqID");
		m_colLabels.Add("commodityID", @"商品条码");
		colNames.Add("commodityID");
		m_colLabels.Add("storagePrice", @"库存均价");
		colNames.Add("storagePrice");
		m_colLabels.Add("storageAmount", @"库存量");
		colNames.Add("storageAmount");
		m_colLabels.Add("storageMoney", @"库存额");
		colNames.Add("storageMoney");
		m_colLabels.Add("unitAmount", @"单位");
		colNames.Add("unitAmount");
		m_colLabels.Add("onSaleAmount", @"上架数量");
		colNames.Add("onSaleAmount");
		m_colLabels.Add("saleAmount", @"销售量");
		colNames.Add("saleAmount");
		m_colLabels.Add("saleMoney", @"销售额");
		colNames.Add("saleMoney");
		m_colLabels.Add("saleCostMoney", @"销售成本");
		colNames.Add("saleCostMoney");
		m_colLabels.Add("stockAmount", @"入库数量");
		colNames.Add("stockAmount");
		m_colLabels.Add("stockMoney", @"入库金额");
		colNames.Add("stockMoney");
		m_colLabels.Add("returnedAmount", @"退货数量");
		colNames.Add("returnedAmount");
		m_colLabels.Add("returnedMoney", @"退货金额");
		colNames.Add("returnedMoney");
		m_colLabels.Add("returnedCostMoney", @"退货成本");
		colNames.Add("returnedCostMoney");
		m_colLabels.Add("lossMoney", @"损耗金额");
		colNames.Add("lossMoney");
	  }
	
	}
	public Object uniqueResult(DetachedCriteria dc)
    {
        return dao.uniqueResult(dc);
    }
	 public DetachedCriteria DC 
     {
        	get{return DetachedCriteria.For(typeof(Storage));}
     }
	public const string ENTITYNAME="t_storage";
	public const int SEQN0=120;
	
    public void checkAdd()
    {
		int len;
	//try{Convert.ToInt64(seqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	seqID<consts.long_min+1)
			throw (new Exception("请输入编号"));
 if(				(				  string.Format("{0}",seqID)				  )=="0")
	 throw (new Exception("编号是主健，框架要求值不能为0"));				

	
	len=commodityID.Trim().Length;
	if(len>50)
		 throw (new Exception("商品条码字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品条码不能为空!"));	
	

	//try{Convert.ToDouble(storagePrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	storagePrice<consts.double_min+1)
			throw (new Exception("请输入库存均价"));
	

	//try{Convert.ToDouble(storageAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	storageAmount<consts.double_min+1)
			throw (new Exception("请输入库存量"));
		if(storageAmount>0)
			storageAmount+=0.000001;
		if(storageAmount<0)
			storageAmount-=0.000001;
		
			if(((long)((storageAmount)*100 ))*10!=(long)((storageAmount)*1000) )
				throw (new Exception("库存量小数精度不能大于2位storageAmount="+storageAmount.ToString()));
		if(storageAmount>0)
			storageAmount-=0.000001;
		if(storageAmount<0)
			storageAmount+=0.000001;
	

//do not check storageMoney 

	//try{Convert.ToDouble(unitAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	unitAmount<consts.double_min+1)
			throw (new Exception("请输入单位"));
	

	//try{Convert.ToDouble(onSaleAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	onSaleAmount<consts.double_min+1)
			throw (new Exception("请输入上架数量"));
		if(onSaleAmount>0)
			onSaleAmount+=0.000001;
		if(onSaleAmount<0)
			onSaleAmount-=0.000001;
		
			if(((long)((onSaleAmount)*100 ))*10!=(long)((onSaleAmount)*1000) )
				throw (new Exception("上架数量小数精度不能大于2位onSaleAmount="+onSaleAmount.ToString()));
		if(onSaleAmount>0)
			onSaleAmount-=0.000001;
		if(onSaleAmount<0)
			onSaleAmount+=0.000001;
	

	//try{Convert.ToDouble(saleAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	saleAmount<consts.double_min+1)
			throw (new Exception("请输入销售量"));
		if(saleAmount>0)
			saleAmount+=0.000001;
		if(saleAmount<0)
			saleAmount-=0.000001;
		
			if(((long)((saleAmount)*100 ))*10!=(long)((saleAmount)*1000) )
				throw (new Exception("销售量小数精度不能大于2位saleAmount="+saleAmount.ToString()));
		if(saleAmount>0)
			saleAmount-=0.000001;
		if(saleAmount<0)
			saleAmount+=0.000001;
	

	//try{Convert.ToDouble(saleMoney);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	saleMoney<consts.double_min+1)
			throw (new Exception("请输入销售额"));
	

//do not check saleCostMoney 

	//try{Convert.ToDouble(stockAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	stockAmount<consts.double_min+1)
			throw (new Exception("请输入入库数量"));
		if(stockAmount>0)
			stockAmount+=0.000001;
		if(stockAmount<0)
			stockAmount-=0.000001;
		
			if(((long)((stockAmount)*100 ))*10!=(long)((stockAmount)*1000) )
				throw (new Exception("入库数量小数精度不能大于2位stockAmount="+stockAmount.ToString()));
		if(stockAmount>0)
			stockAmount-=0.000001;
		if(stockAmount<0)
			stockAmount+=0.000001;
	

//do not check stockMoney 

	//try{Convert.ToDouble(returnedAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	returnedAmount<consts.double_min+1)
			throw (new Exception("请输入退货数量"));
		if(returnedAmount>0)
			returnedAmount+=0.000001;
		if(returnedAmount<0)
			returnedAmount-=0.000001;
		
			if(((long)((returnedAmount)*100 ))*10!=(long)((returnedAmount)*1000) )
				throw (new Exception("退货数量小数精度不能大于2位returnedAmount="+returnedAmount.ToString()));
		if(returnedAmount>0)
			returnedAmount-=0.000001;
		if(returnedAmount<0)
			returnedAmount+=0.000001;
	

//do not check returnedMoney 

//do not check returnedCostMoney 

//do not check lossMoney 

//unique="yes" 唯一性验证
		ICriterion crit=Restrictions.Eq("commodityID", commodityID);
  		IList list=dao.List(dao.DC.Add(crit));
		if(list.Count==0)
			return;
		Storage obj=list[0] as Storage;
//唯一性异常消息抛出
		if( obj.commodityID==commodityID)
		{
			throw (new Exception(string.Format("商品条码:{0}已经存在",commodityID)));	
		}
	//end unique="yes" 唯一性验证
    }
    public void checkUpdate()
    {
		int len;
	//try{Convert.ToInt64(seqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	seqID<consts.long_min+1)
			throw (new Exception("请输入编号"));
 if(				(				  string.Format("{0}",seqID)				  )=="0")
	 throw (new Exception("编号是主健，框架要求值不能为0"));				

	
	len=commodityID.Trim().Length;
	if(len>50)
		 throw (new Exception("商品条码字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品条码不能为空!"));	
	

	//try{Convert.ToDouble(storagePrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	storagePrice<consts.double_min+1)
			throw (new Exception("请输入库存均价"));
	

	//try{Convert.ToDouble(storageAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	storageAmount<consts.double_min+1)
			throw (new Exception("请输入库存量"));
		if(storageAmount>0)
			storageAmount+=0.000001;
		if(storageAmount<0)
			storageAmount-=0.000001;
		
			if(((long)((storageAmount)*100 ))*10!=(long)((storageAmount)*1000) )
				throw (new Exception("库存量小数精度不能大于2位storageAmount="+storageAmount.ToString()));
		if(storageAmount>0)
			storageAmount-=0.000001;
		if(storageAmount<0)
			storageAmount+=0.000001;
	

//do not check storageMoney 

	//try{Convert.ToDouble(unitAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	unitAmount<consts.double_min+1)
			throw (new Exception("请输入单位"));
	

	//try{Convert.ToDouble(onSaleAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	onSaleAmount<consts.double_min+1)
			throw (new Exception("请输入上架数量"));
		if(onSaleAmount>0)
			onSaleAmount+=0.000001;
		if(onSaleAmount<0)
			onSaleAmount-=0.000001;
		
			if(((long)((onSaleAmount)*100 ))*10!=(long)((onSaleAmount)*1000) )
				throw (new Exception("上架数量小数精度不能大于2位onSaleAmount="+onSaleAmount.ToString()));
		if(onSaleAmount>0)
			onSaleAmount-=0.000001;
		if(onSaleAmount<0)
			onSaleAmount+=0.000001;
	

	//try{Convert.ToDouble(saleAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	saleAmount<consts.double_min+1)
			throw (new Exception("请输入销售量"));
		if(saleAmount>0)
			saleAmount+=0.000001;
		if(saleAmount<0)
			saleAmount-=0.000001;
		
			if(((long)((saleAmount)*100 ))*10!=(long)((saleAmount)*1000) )
				throw (new Exception("销售量小数精度不能大于2位saleAmount="+saleAmount.ToString()));
		if(saleAmount>0)
			saleAmount-=0.000001;
		if(saleAmount<0)
			saleAmount+=0.000001;
	

	//try{Convert.ToDouble(saleMoney);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	saleMoney<consts.double_min+1)
			throw (new Exception("请输入销售额"));
	

//do not check saleCostMoney 

	//try{Convert.ToDouble(stockAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	stockAmount<consts.double_min+1)
			throw (new Exception("请输入入库数量"));
		if(stockAmount>0)
			stockAmount+=0.000001;
		if(stockAmount<0)
			stockAmount-=0.000001;
		
			if(((long)((stockAmount)*100 ))*10!=(long)((stockAmount)*1000) )
				throw (new Exception("入库数量小数精度不能大于2位stockAmount="+stockAmount.ToString()));
		if(stockAmount>0)
			stockAmount-=0.000001;
		if(stockAmount<0)
			stockAmount+=0.000001;
	

//do not check stockMoney 

	//try{Convert.ToDouble(returnedAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	returnedAmount<consts.double_min+1)
			throw (new Exception("请输入退货数量"));
		if(returnedAmount>0)
			returnedAmount+=0.000001;
		if(returnedAmount<0)
			returnedAmount-=0.000001;
		
			if(((long)((returnedAmount)*100 ))*10!=(long)((returnedAmount)*1000) )
				throw (new Exception("退货数量小数精度不能大于2位returnedAmount="+returnedAmount.ToString()));
		if(returnedAmount>0)
			returnedAmount-=0.000001;
		if(returnedAmount<0)
			returnedAmount+=0.000001;
	

//do not check returnedMoney 

//do not check returnedCostMoney 

//do not check lossMoney 

//unique="yes" 唯一性验证
		ICriterion crit=Restrictions.Eq("seqID", seqID);
		crit=Restrictions.Or(crit,Restrictions.Eq("commodityID", commodityID));
  		IList list=dao.List(dao.DC.Add(crit));
		if(list.Count==1)
			return;
		if(list.Count==0)
			throw (new Exception("该记录已经被删除"));	
		else
			throw (new Exception("改纪录出现重名!"));
    }
    public void add()
    {
        try
        {
            checkAdd();
         	dao.Add(__storage);
        }
        catch(Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
   
    public void delByseqID()
    {
    
        try
        {
          dao.Delete(__storage);
        }
        catch(Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }

    public  void update()
    {
        try
        {
            checkUpdate();
            dao.Update(__storage);
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
   
    public void ExecDataUpdate(int rowNo)
    {
		if(m_updateRow==null)
			return;
		int ii=0;
m_updateRow(rowNo,ii++,				(				  string.Format("{0}",seqID)				  ));	
m_updateRow(rowNo,ii++,commodityID);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F0}",storagePrice)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",storageAmount)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F0}",storageMoney)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F0}",unitAmount)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",onSaleAmount)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",saleAmount)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F0}",saleMoney)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F0}",saleCostMoney)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",stockAmount)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F0}",stockMoney)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",returnedAmount)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",returnedMoney)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",returnedCostMoney)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F0}",lossMoney)/***/)
);	

    }
    public void ExecHeadInsert()
    {
		if(m_insertHead!=null)
        {
			int ii=0;
			m_insertHead(ii++,60,"编号");
			m_insertHead(ii++,100,"商品条码");
			m_insertHead(ii++,100,"库存均价");
			m_insertHead(ii++,100,"库存量");
			m_insertHead(ii++,100,"库存额");
			m_insertHead(ii++,100,"单位");
			m_insertHead(ii++,100,"上架数量");
			m_insertHead(ii++,100,"销售量");
			m_insertHead(ii++,100,"销售额");
			m_insertHead(ii++,100,"销售成本");
			m_insertHead(ii++,100,"入库数量");
			m_insertHead(ii++,100,"入库金额");
			m_insertHead(ii++,100,"退货数量");
			m_insertHead(ii++,100,"退货金额");
			m_insertHead(ii++,100,"退货成本");
			m_insertHead(ii++,90,"损耗金额");
		}		
    }
    public void ExecDataInsert()
	{
		if(m_insertRow==null)
			return;
		int ii=0;
     	m_insertRow(0,ii++,				(				  string.Format("{0}",seqID)				  ));
     	m_insertRow(0,ii++,commodityID);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F0}",storagePrice)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",storageAmount)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F0}",storageMoney)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F0}",unitAmount)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",onSaleAmount)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",saleAmount)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F0}",saleMoney)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F0}",saleCostMoney)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",stockAmount)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F0}",stockMoney)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",returnedAmount)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",returnedMoney)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",returnedCostMoney)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F0}",lossMoney)/***/)
);
    }
    public void ExecDataInsertByQuery(DetachedCriteria dc)
    {
      
         IList list=dao.List(dc); 
        
        if(m_insertHead!=null)
        {
			int ii=0;
			m_insertHead(ii++,60,"编号");
			m_insertHead(ii++,100,"商品条码");
			m_insertHead(ii++,100,"库存均价");
			m_insertHead(ii++,100,"库存量");
			m_insertHead(ii++,100,"库存额");
			m_insertHead(ii++,100,"单位");
			m_insertHead(ii++,100,"上架数量");
			m_insertHead(ii++,100,"销售量");
			m_insertHead(ii++,100,"销售额");
			m_insertHead(ii++,100,"销售成本");
			m_insertHead(ii++,100,"入库数量");
			m_insertHead(ii++,100,"入库金额");
			m_insertHead(ii++,100,"退货数量");
			m_insertHead(ii++,100,"退货金额");
			m_insertHead(ii++,100,"退货成本");
			m_insertHead(ii++,90,"损耗金额");
		}		
		
      if(m_insertRow!=null)
      {
        int j=0;
        foreach(Storage obj in list)			
        {
		  int ii=0;
	     
m_insertRow(j,ii++,				(				  string.Format("{0}",obj.seqID)
				  )
);
m_insertRow(j,ii++,obj.commodityID.ToString());
m_insertRow(j,ii++,(					string.Format("{0:F0}",obj.storagePrice)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.storageAmount)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F0}",obj.storageMoney)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F0}",obj.unitAmount)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.onSaleAmount)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.saleAmount)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F0}",obj.saleMoney)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F0}",obj.saleCostMoney)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.stockAmount)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F0}",obj.stockMoney)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.returnedAmount)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.returnedMoney)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.returnedCostMoney)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F0}",obj.lossMoney)
					)
);
		j++;
        }
        

	
       }
    }

    
    public IList List(DetachedCriteria dc)
    {
        try
        {
           
            return dao.List(dc);
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
    
    public bool Init(DetachedCriteria dc)
    {
    
    		Storage obj=dao.Get(dc);
    		if(obj==null)
    			return false;
    		else
    		{
    			__storage=obj;
            	return true;
            }
        
    }
    public static t_storage Get(DetachedCriteria dc)
    {
    	
    	Storage obj=((StorageDao)SpringContext.Context.GetObject("StorageDao"))
	 	.Get(dc);
	 	if(obj==null)
	 		return null;
	 	else
	 		return new t_storage( obj );
        
    }
	 public static t_storage GetBySeqID(long val)
	 {
	 	Storage obj=((StorageDao)SpringContext.Context.GetObject("StorageDao"))
	 	.GetBySeqID(val);
	 	if(obj==null)
	 		return null;
	 	else
	 		return new t_storage( obj );
	 	
	 	
	 }
	 public  bool InitBySeqID(long val)
	 {
	 	

	 	Storage obj=dao.GetBySeqID(val) ;
	 	if(obj==null)
	 		return false;
	 	else
	 	{
	 		__storage=obj;
	 		return true;
	 	}
	 	
	 	
	 }
	 public static t_storage GetByCommodityID(String val)
	 {
	 	Storage obj=((StorageDao)SpringContext.Context.GetObject("StorageDao"))
	 	.GetByCommodityID(val);
	 	if(obj==null)
	 		return null;
	 	else
	 		return new t_storage( obj );
	 	
	 	
	 }
	 public  bool InitByCommodityID(String val)
	 {
	 	

	 	Storage obj=dao.GetByCommodityID(val) ;
	 	if(obj==null)
	 		return false;
	 	else
	 	{
	 		__storage=obj;
	 		return true;
	 	}
	 	
	 	
	 }
    
       public bool showInForm(Control.ControlCollection Controls)
    {
        try
        {
             
		if(Controls["seqID"]!=null)
		{
			Controls["seqID"].Text=				(				  string.Format("{0}",seqID)				  );
		}
		if(Controls["commodityID"]!=null)
		{
			Controls["commodityID"].Text=commodityID;
		}
		if(Controls["storagePrice"]!=null)
		{
			Controls["storagePrice"].Text=/***/(						string.Format("{0:F0}",storagePrice)/***/)
;
		}
		if(Controls["storageAmount"]!=null)
		{
			Controls["storageAmount"].Text=/***/(						string.Format("{0:F2}",storageAmount)/***/)
;
		}
		if(Controls["storageMoney"]!=null)
		{
			Controls["storageMoney"].Text=/***/(						string.Format("{0:F0}",storageMoney)/***/)
;
		}
		if(Controls["unitAmount"]!=null)
		{
			Controls["unitAmount"].Text=/***/(						string.Format("{0:F0}",unitAmount)/***/)
;
		}
		if(Controls["onSaleAmount"]!=null)
		{
			Controls["onSaleAmount"].Text=/***/(						string.Format("{0:F2}",onSaleAmount)/***/)
;
		}
		if(Controls["saleAmount"]!=null)
		{
			Controls["saleAmount"].Text=/***/(						string.Format("{0:F2}",saleAmount)/***/)
;
		}
		if(Controls["saleMoney"]!=null)
		{
			Controls["saleMoney"].Text=/***/(						string.Format("{0:F0}",saleMoney)/***/)
;
		}
		if(Controls["saleCostMoney"]!=null)
		{
			Controls["saleCostMoney"].Text=/***/(						string.Format("{0:F0}",saleCostMoney)/***/)
;
		}
		if(Controls["stockAmount"]!=null)
		{
			Controls["stockAmount"].Text=/***/(						string.Format("{0:F2}",stockAmount)/***/)
;
		}
		if(Controls["stockMoney"]!=null)
		{
			Controls["stockMoney"].Text=/***/(						string.Format("{0:F0}",stockMoney)/***/)
;
		}
		if(Controls["returnedAmount"]!=null)
		{
			Controls["returnedAmount"].Text=/***/(						string.Format("{0:F2}",returnedAmount)/***/)
;
		}
		if(Controls["returnedMoney"]!=null)
		{
			Controls["returnedMoney"].Text=/***/(						string.Format("{0:F2}",returnedMoney)/***/)
;
		}
		if(Controls["returnedCostMoney"]!=null)
		{
			Controls["returnedCostMoney"].Text=/***/(						string.Format("{0:F2}",returnedCostMoney)/***/)
;
		}
		if(Controls["lossMoney"]!=null)
		{
			Controls["lossMoney"].Text=/***/(						string.Format("{0:F0}",lossMoney)/***/)
;
		}
			return true;
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
            
        }
    }
    public  t_storage Init(Storage item)
    {
        __storage=item;
        return this;
    }

    
     public bool initByForm(Control.ControlCollection Controls)
    {
        try
        {
             
		if(Controls["seqID"]!=null)
		{
			
			if(Controls["seqID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["seqID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{seqID=(v==""?consts.long_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["seqID"].Focus();
					throw  (new Exception("编号格式不正确！！"));
				}
				
			}
			else
			{
				try{seqID=(Controls["seqID"].Text==""?consts.long_min:Convert.ToInt32(Controls["seqID"].Text));}
				catch
				{
					 Controls["seqID"].Focus();
					throw  (new Exception("编号格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityID"]!=null)
		{
			
			if(Controls["commodityID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityID=v;}
				catch
				{
					 Controls["commodityID"].Focus();
					throw  (new Exception("商品条码格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityID=Controls["commodityID"].Text;}
				catch
				{
					 Controls["commodityID"].Focus();
					throw  (new Exception("商品条码格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["storagePrice"]!=null)
		{
			
			if(Controls["storagePrice"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["storagePrice"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{storagePrice=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["storagePrice"].Focus();
					throw  (new Exception("库存均价格式不正确！！"));
				}
				
			}
			else
			{
				try{storagePrice=(Controls["storagePrice"].Text==""?consts.double_min:Convert.ToDouble(Controls["storagePrice"].Text));}
				catch
				{
					 Controls["storagePrice"].Focus();
					throw  (new Exception("库存均价格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["storageAmount"]!=null)
		{
			
			if(Controls["storageAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["storageAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{storageAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["storageAmount"].Focus();
					throw  (new Exception("库存量格式不正确！！"));
				}
				
			}
			else
			{
				try{storageAmount=(Controls["storageAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["storageAmount"].Text));}
				catch
				{
					 Controls["storageAmount"].Focus();
					throw  (new Exception("库存量格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["storageMoney"]!=null)
		{
			
			if(Controls["storageMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["storageMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{storageMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["storageMoney"].Focus();
					throw  (new Exception("库存额格式不正确！！"));
				}
				
			}
			else
			{
				try{storageMoney=(Controls["storageMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["storageMoney"].Text));}
				catch
				{
					 Controls["storageMoney"].Focus();
					throw  (new Exception("库存额格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["unitAmount"]!=null)
		{
			
			if(Controls["unitAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["unitAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{unitAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["unitAmount"].Focus();
					throw  (new Exception("单位格式不正确！！"));
				}
				
			}
			else
			{
				try{unitAmount=(Controls["unitAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["unitAmount"].Text));}
				catch
				{
					 Controls["unitAmount"].Focus();
					throw  (new Exception("单位格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["onSaleAmount"]!=null)
		{
			
			if(Controls["onSaleAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["onSaleAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{onSaleAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["onSaleAmount"].Focus();
					throw  (new Exception("上架数量格式不正确！！"));
				}
				
			}
			else
			{
				try{onSaleAmount=(Controls["onSaleAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["onSaleAmount"].Text));}
				catch
				{
					 Controls["onSaleAmount"].Focus();
					throw  (new Exception("上架数量格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["saleAmount"]!=null)
		{
			
			if(Controls["saleAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["saleAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{saleAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["saleAmount"].Focus();
					throw  (new Exception("销售量格式不正确！！"));
				}
				
			}
			else
			{
				try{saleAmount=(Controls["saleAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["saleAmount"].Text));}
				catch
				{
					 Controls["saleAmount"].Focus();
					throw  (new Exception("销售量格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["saleMoney"]!=null)
		{
			
			if(Controls["saleMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["saleMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{saleMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["saleMoney"].Focus();
					throw  (new Exception("销售额格式不正确！！"));
				}
				
			}
			else
			{
				try{saleMoney=(Controls["saleMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["saleMoney"].Text));}
				catch
				{
					 Controls["saleMoney"].Focus();
					throw  (new Exception("销售额格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["saleCostMoney"]!=null)
		{
			
			if(Controls["saleCostMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["saleCostMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{saleCostMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["saleCostMoney"].Focus();
					throw  (new Exception("销售成本格式不正确！！"));
				}
				
			}
			else
			{
				try{saleCostMoney=(Controls["saleCostMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["saleCostMoney"].Text));}
				catch
				{
					 Controls["saleCostMoney"].Focus();
					throw  (new Exception("销售成本格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["stockAmount"]!=null)
		{
			
			if(Controls["stockAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["stockAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{stockAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["stockAmount"].Focus();
					throw  (new Exception("入库数量格式不正确！！"));
				}
				
			}
			else
			{
				try{stockAmount=(Controls["stockAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["stockAmount"].Text));}
				catch
				{
					 Controls["stockAmount"].Focus();
					throw  (new Exception("入库数量格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["stockMoney"]!=null)
		{
			
			if(Controls["stockMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["stockMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{stockMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["stockMoney"].Focus();
					throw  (new Exception("入库金额格式不正确！！"));
				}
				
			}
			else
			{
				try{stockMoney=(Controls["stockMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["stockMoney"].Text));}
				catch
				{
					 Controls["stockMoney"].Focus();
					throw  (new Exception("入库金额格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["returnedAmount"]!=null)
		{
			
			if(Controls["returnedAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["returnedAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{returnedAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["returnedAmount"].Focus();
					throw  (new Exception("退货数量格式不正确！！"));
				}
				
			}
			else
			{
				try{returnedAmount=(Controls["returnedAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["returnedAmount"].Text));}
				catch
				{
					 Controls["returnedAmount"].Focus();
					throw  (new Exception("退货数量格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["returnedMoney"]!=null)
		{
			
			if(Controls["returnedMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["returnedMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{returnedMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["returnedMoney"].Focus();
					throw  (new Exception("退货金额格式不正确！！"));
				}
				
			}
			else
			{
				try{returnedMoney=(Controls["returnedMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["returnedMoney"].Text));}
				catch
				{
					 Controls["returnedMoney"].Focus();
					throw  (new Exception("退货金额格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["returnedCostMoney"]!=null)
		{
			
			if(Controls["returnedCostMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["returnedCostMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{returnedCostMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["returnedCostMoney"].Focus();
					throw  (new Exception("退货成本格式不正确！！"));
				}
				
			}
			else
			{
				try{returnedCostMoney=(Controls["returnedCostMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["returnedCostMoney"].Text));}
				catch
				{
					 Controls["returnedCostMoney"].Focus();
					throw  (new Exception("退货成本格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["lossMoney"]!=null)
		{
			
			if(Controls["lossMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["lossMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{lossMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["lossMoney"].Focus();
					throw  (new Exception("损耗金额格式不正确！！"));
				}
				
			}
			else
			{
				try{lossMoney=(Controls["lossMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["lossMoney"].Text));}
				catch
				{
					 Controls["lossMoney"].Focus();
					throw  (new Exception("损耗金额格式不正确！！"));
				}
				
			}
				
				
		}
			return true;
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
            
        }
    }
    

}

}
